function Animal(type, name, age, sex) {
    this.type = type;
    this.name = name;
    this.age = age;
    this.sex = sex;
}
Animal.prototype.print = function () {
    console.log(`【种类】：${this.type}`);
    console.log(`【名字】：${this.name}`);
    console.log(`【年龄】：${this.age}`);
    console.log(`【性别】：${this.sex}`);
}

function Dog(name, age, sex) {
    //借用父类的构造函数，这个操作是必须的，因为子类包含父类的所有实例成员
    Animal.call(this, "犬类", name, age, sex);
    this.loves = "吃骨头";
}

// 和圣杯模式差不多
Object.setPrototypeOf(Dog.prototype, Animal.prototype); //把 Dog.prototype 的隐式原型设置为 Animal.prototype

const d = new Dog("旺财", 3, "公");
console.log(d);
d.print();
